#pragma once

#include<string>
#include<list>
#include "stream/event.h"


extern "C"
{
#include <libavformat/avformat.h>
}

class DetectObjsInfo;

class Record
{
public:
	Record(std::string sn, int recsize);
	~Record();

	bool IsSaveing(void);

	void DetectObjsToSave(AVFormatContext* ictx, DetectObjsInfo* objs);
	
	AVPacket* GetPkg(void);

	
private:
	void SaveToFile();

	void PostEvent();

private:
	std::string				filename_;
	std::string				sn_;

	AVFormatContext*		fmt_ctx_;
	AVRational				time_base_;


	AVPacket**			pkt_list_;
	int					pkg_size_;
	int					pkg_idx_;

	bool				saveing_;
	int					pkg_save_size_;
	int					pkg_save_count_;
	int					pkg_rec_idx_;

	DetectObjsInfo*		objsinof_;

	Event				event_;
};
